<template>
  <view class="fixedTop">
    <view class="top-nav-box">
      <view class="nav-back" @click="navBack()">
        <view class="image-wrapper"><image src="https://duomi.bigchun.com/images/black-back.png" mode="aspectFit"></image></view>
      </view>
      <template v-if="isOrder=='3'">
        <view class="head_box">
          <u-search shape="square" action-text="" :action-style="{'display':'none'}" v-model="searchVals" padding="30rpx" placeholder="搜索商品" height="64" @search="onSearch" @clear="clearSearch"></u-search>
        </view>
      </template>
      <view v-else class="nav-txt flex1">{{ title }}</view>
      <slot></slot>
    </view>

    <!-- 客服组件 -->
<!--    <order-telephone name="如有技术问题请联系" phoneNumber="18820268653" ref="telephoneServiceTel"></order-telephone>-->
  </view>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex';
export default {
  props:{
    title:{
      type: String,
      default: ''
    },
    isOrder: {
      type: String,
      default: '3'
    },
    searchVal: {
      type: String,
      default: ''
    },
  },
  computed: {
    // ...mapGetters(['userInfo'])
  },
  data() {
    return {
      searchVals:''
    };
  },
  created() {
    this.searchVals = this.searchVal
  },
  methods: {
    navBack() {
      if (this.title!='首页搜索'&&this.title != '登录'){
        this.$store.dispatch('showAuthModal', 'toLogin');
      }else{
        uni.navigateBack()
      }
    },
    // 搜索
    onSearch(e) {
     this.$emit('onSearch',e)
    },
    clearSearch() {
      this.$emit('clearSearch')
    },
  }
};
</script>

<style lang="scss">
.top-nav-box {
  background: #fff;
  color: #000;
  text-align: center;
  position: relative;
  height: 88rpx;
  line-height: 88rpx;
  font-size: 32rpx;
  display: flex;
  width: 100%;
  .nav-txt {
    font-size: 32rpx;
  }
  .flex1{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-weight: bold;
    .type-item{
      font-size: 16px;
    }
    .type-item:first-child{
      margin-right: 40px;
    }
    .active{
      color:#FFC801;
    }
  }
  .nav-back {
    width: 88rpx;
    height: 88rpx;
    position: absolute;
    top: 0;
    left: 0;
    .image-wrapper {
      margin-left: 14rpx;
      box-sizing: border-box;
      width: 34rpx;
      height: 34rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
  }
  .head_box{
    margin-left: 88rpx;
    width: 80%;
    margin: 12rpx auto;
  }
  .nav-right {
    display: flex;
    padding-right: 20rpx;
    position: absolute;
    top: 0;
    right: 0;
    .image-wrapper {
      margin-top: 10rpx;
      margin-right: 20rpx;
      width: 70rpx;
      height: 70rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
    .image-wrapper2 {
      margin-top: 15rpx;
      width: 50rpx;
      height: 50rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
    .nar-right-txt {
      font-size: 32rpx;
    }
  }
}
</style>
